#include "SimpleWindow.h"

namespace sw {
bool registerWindowClass()
{
	WNDCLASS wc = {};
	wc.lpszClassName = defaultWindowClassName;
	wc.lpfnWndProc = DefWindowProc;
	wc.hInstance = GetModuleHandle(nullptr);
	wc.style = CS_OWNDC;

	return RegisterClass(&wc);
}

HWND createWindow()
{

	return CreateWindowEx(
		0,
		defaultWindowClassName, defaultWindowName,
		WS_OVERLAPPED|WS_SYSMENU,
		CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
		nullptr, nullptr,
		GetModuleHandle(nullptr),
		nullptr
	);
}

HWND createWindow(int w, int h)
{
	HWND hwnd = createWindow();
	RECT r = {0,0,w,h};
	AdjustWindowRect(&r, WS_OVERLAPPED, false);
	
	SetWindowPos(hwnd, HWND_NOTOPMOST, 300, 300,
		r.right - r.left, r.bottom - r.top,
		SWP_NOMOVE);
	
	return hwnd;
}

void setWindowProc(HWND hwnd,WNDPROC proc)
{
	SetWindowLong(hwnd, GWLP_WNDPROC, (LONG)proc);
}

}

